<?php
namespace app\index\controller;

use think\Controller;
use think\Db;

class StatsController extends  Controller{
    public function index(){
      return  $this->fetch();
    }
    public function getlist(){
        $stime=strtotime(input('stime')) ;
        $dtime=strtotime(input('dtime')) ;

        $str="SELECT id,name,sumgs,jiaban,qingjia
FROM
(SELECT
gs_member_gsrecord.member_id,
sum(gsvalue) AS sumgs
FROM gs_member_gsrecord, gs_gsrecord
WHERE gs_member_gsrecord.gsrecord_id = gs_gsrecord.id AND gs_gsrecord.pend = 1 AND starttime BETWEEN $stime AND $dtime
GROUP BY gs_member_gsrecord.member_id)

AS C
RIGHT JOIN gs_member ON C.member_id=gs_member.id
LEFT JOIN
  (SELECT
     member_id, sum(if(leixing=1,duration,0))  as jiaban , sum(if(leixing=0,duration,0))  as qingjia
   FROM gs_level  WHERE pend=1 AND status=0 AND starttime BETWEEN $stime AND $dtime GROUP BY member_id) AS D ON d.member_id=C.member_id";
        $record=Db::query($str);
        return json(['data'=>$record]);
    }
}


